import { defineAsyncComponent } from 'vue'
export { confirm } from './confirm/index.js'
export { message } from './message/index.js'

export default {
  // app就是createApp返回的vue实例
  install(app) {
    // 注册组件
    // 批量导入
    // 1.获取当前目录文件夹下的index.vue
    const components = import.meta.glob('./*/index.vue')
    // 2.便利获取到的模块
    for (const [fullPath, fn] of Object.entries(components)) {
      // 3.利用app.component 循环注册
      const name = 'm-' + fullPath.replace('./', '').split('/')[0]
      app.component(name, defineAsyncComponent(fn))
    }
  }
}
